package com.jzr.bedside.ui

import android.content.Intent
import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson
import com.jzr.bedside.R
import com.jzr.bedside.base.BaseActivity
import com.jzr.bedside.base.Constant
import com.jzr.bedside.bean.SkillListBean
import com.jzr.bedside.ui.adapter.SkillMainAdapter
import com.jzr.bedside.ui.skill.*
import kotlinx.android.synthetic.main.actionbar_root_layout.*
import kotlinx.android.synthetic.main.activity_skill_main.*

// 技能中心
class SkillMainActivity : BaseActivity(), View.OnClickListener, SkillMainAdapter.onListItemClick {

    private var adapter: SkillMainAdapter? = null
    private var dataSkill = mutableListOf<SkillListBean>()

    override fun getLayoutId(): Int {
        return R.layout.activity_skill_main
    }

    override fun attachView() {

    }

    override fun detachView() {

    }

    override fun initView() {

        ivRight.setOnClickListener(this)

        for ((index, item) in Constant.drawableId.withIndex()) {
            val skillListBean = SkillListBean()
            skillListBean.id = index
            skillListBean.drawableId = item
            dataSkill.add(skillListBean)
        }

        adapter = SkillMainAdapter(dataSkill)
        rvSkill.adapter = adapter
        val manager = GridLayoutManager(this, 4, RecyclerView.VERTICAL, false)
        rvSkill.layoutManager = manager
        adapter?.onListItemClick(this)

    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.ivRight -> {
                finish()
            }
        }
    }

    override fun onListItemClick(item: SkillListBean?) {
        when (item?.id) {
            0 -> {
                val i = Intent(this, HospitalDetailsActivity::class.java)
                startActivityIn(i, this)
            }

            2 -> {
                val i = Intent(this, EvaluationActivity::class.java)
                startActivityIn(i, this)
            }

            3 -> {
                val i = Intent(this, MultimediaActivity::class.java)
                startActivityIn(i, this)
            }

            4 -> {
                val i = Intent(this, FeeActivity::class.java)
                startActivityIn(i, this)
            }

            6 -> {
                val i = Intent(this, DrugActivity::class.java)
                startActivityIn(i, this)
            }

            8->{
                val i = Intent(this, OximeterActivity::class.java)
                startActivityIn(i, this)
            }

            9->{
                val i = Intent(this, TemperatureActivity::class.java)
                startActivityIn(i, this)
            }

            10->{
                val i = Intent(this, BloodPressureActivity::class.java)
                startActivityIn(i, this)
            }

            11 -> {
                val i = Intent(this, TestActivity::class.java)
                startActivityIn(i, this)
            }

            12 -> {
                val i = Intent(this, InspectActivity::class.java)
                startActivityIn(i, this)
            }

        }
    }

}
